<?php
    /**
    * Get media action
    * Get media player HTML by music ID
    * 
    * Change logs
    * Apr 12, 2011 - Trungdt - Add no_autostart param
    */
    if (!defined("EXPONENT")) exit("");

    $music = null;
    $music_id=-1;

    global $_SERVER;
    $is_IE=false;
    if (isset($_SERVER['HTTP_USER_AGENT']) && 
    (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') >0 ))
        $is_IE=true;
    else
        $ie_IE=false;

    if (isset($_GET['id'])) {
        $homepage_mode=0;
        if (isset($_GET['type']) && ($_GET['type']=='homepage'))
        {
            $homepage_mode=1;
        }
        $auto_start=true;
        if (isset($_REQUEST['no_autostart']))
        {
            $auto_start=false;
        }
        
        $music_id  = intval($_REQUEST['id']);
        $musics=$db->selectObject("musics","id = {$music_id}");
        
        if ($musics!= null) {
            // build json
            $obj_json=null;
            $obj_json->id=$musics->id;
            $obj_json->singer=$musics->singer;
            $obj_json->name=$musics->name;
            $obj_json->media_html=albummodule::getMediaPlayer($musics, $homepage_mode,$auto_start);
            $obj_json->width=188;
            $obj_json->height=200;
            
            $ret=json_encode($obj_json);
            echo $ret;
        }
        else {
            echo "";
            die(); //  not allow
        }
    }




?>
